<?php
	if($id == FALSE){
		$tanggal_dibuat	= set_value("tanggal_dibuat");
		$deadline		= set_value("deadline");
		$keterangan		= set_value("keterangan");
	} else {
		$tanggal_dibuat	= (set_value("tanggal_dibuat") == "") ? (date('d-m-Y', strtotime($value["tanggal_dibuat"]))) : (set_value("tanggal_dibuat"));
		$deadline		= (set_value("deadline") == "") ? (date('d-m-Y', strtotime($value["deadline"]))) : (set_value("deadline"));
		$keterangan		= (set_value("keterangan") == "") ? ($value["keterangan"]) : (set_value("keterangan"));
	}
?>

<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h4>
					<span>Form Tindak Lanjut</span>
				</h4>
			</div>
			<div class="panel-body">
				<?php
					$attributes = array('class' => 'form-horizontal', 'id'=>'form-validate', 'role' => 'form');

					if( $id == FALSE ) {
						echo form_open('tindak_lanjut/form_tindak_lanjut/', $attributes);
					}
					else
						echo form_open('tindak_lanjut/form_tindak_lanjut/'.$id, $attributes);
				?>
					<div class="form-group">
						<label class="col-lg-3 control-label" for="">Tanggal Dibuat</label>
						<div class="col-lg-3">
							<input type="text" id="tanggal_dibuat" name="tanggal_dibuat" value="<?php echo $tanggal_dibuat; ?>" class="form-control">
						</div>
					</div><!-- End .form-group  -->
					<div class="form-group">
						<label class="col-lg-3 control-label" for="">Deadline</label>
						<div class="col-lg-3">
							<input type="text" id="deadline" name="deadline" value="<?php echo $deadline; ?>" class="form-control">
						</div>
					</div><!-- End .form-group  -->
                    <div class="form-group">
                        <label class="col-lg-3 control-label" for="select">Pertanyaan</label>
                        <div class="col-lg-9">
							<?php
								$js = ' id="pertanyaan" class="form-control" ' ;
								$selected = set_value('pertanyaan', (isset($value["ID_PERTANYAAN"])) ? $value["ID_PERTANYAAN"] : 0 );
								echo form_dropdown('pertanyaan',$list_pertanyaan,$selected,$js);
							?>
                        </div>
                    </div><!-- End .form-group  -->
					<div class="form-group">
						<label class="col-lg-3 control-label" for="textareas">Keterangan</label>
						<div class="col-lg-6">
							<textarea id="ketarangan" rows="3" cols="40" name="keterangan" class="form-control elastic"><?php echo $keterangan; ?></textarea>
						</div>
					</div><!-- End .form-group  -->
					<div class="form-group">
						<div class="col-lg-offset-3 col-lg-9">
							<button type="submit" class="btn btn-info">Simpan</button>
							<button type="reset" class="btn btn-warning">Reset</button>
							<button type="button" onClick="kembali()" class="btn btn-default">Kembali</button>
						</div>
					</div><!-- End .form-group  -->
				<!-- </form> -->
				<?php
					echo form_close();
				?>
			</div>
		</div>
	</div>
</div><!-- End .panel -->

<script language="javascript">
function kembali(){
	document.location="<?php echo site_url("tindak_lanjut"); ?>";
}

$(document).ready(function() {
	// $( '#tanggal_dibuat' ).datepicker({
	// 	showOtherMonths: true,
	// 	selectOtherMonths: true,
	// 	changeMonth: true,
	// 	changeYear: true,
	// 	dateFormat: 'dd-mm-yy'
	// });

	// $( '#deadline' ).datepicker({
	// 	showOtherMonths: true,
	// 	selectOtherMonths: true,
	// 	changeMonth: true,
	// 	changeYear: true,
	// 	dateFormat: 'dd-mm-yy'
	// });

	if($('#tanggal_dibuat').length) {
		$('#tanggal_dibuat').datepicker({
	        inline: true,
			showOtherMonths:true,
			dateFormat: 'dd-mm-yy'
	    });
	}

	if($('#deadline').length) {
		$('#deadline').datepicker({
	        inline: true,
			showOtherMonths:true,
			dateFormat: 'dd-mm-yy'
	    });
	}

    $("#form-validate").validate({
    	ignore: null,
    	ignore: 'input[type="hidden"]',
    	rules: {
			tanggal_dibuat: "required",
			deadline: "required"
		},
		messages: {
			tanggal_dibuat: "Baris ini wajib diisi !!!",
			deadline: "Baris ini wajib diisi !!!"
		}
    });

});
</script>